{js href="__JS__/ajaxfileupload.js"}

    <!-- 修改头像 -->
    <div class="changeUserPic">
        <div class="preview">
            <div class="previewPic">
                <!--<?php if(empty($icon_url)):?>-->
                <!--<img width="150px" height="150px" src="__IMG__/user_pic.png">-->
                <!--<?php else:?>-->
                <!--<img width="150px" height="150px" src="{$icon_url}">-->
                <!--<?php endif;?>-->
            </div>
            <div class="choosePic">
                <input type="file" id="Filedata" name="Filedata" class="UploadImg" multiple accept="image/*" >
                <span></span>
            </div>
        </div>
        <div class="clear"></div>
        <div class="savePicture">
            <a href="#">保存</a>
        </div>
        <div class="canclePicture">
            <a href="javascript:void">取消</a>
        </div>
    </div>

<script>

    $('.savePicture').click(function(){
        $.ajaxFileUpload({
            url: '/User/changeUserPic',
            type: 'post',
            secureuri: false, //一般设置为false
            fileElementId: 'Filedata', // 上传文件的id、name属性名
            dataType: 'json',
            success:function(list){
                var errCode = list.codeNum;
                var errMsg  = list.msg;
                //errCode为0、1、2、3、5、6均为上传不成功
                if(errCode==0||errCode==1||errCode==2||errCode==3||errCode==5||errCode==6){
                    $('.choosePic span').html(errMsg);
                    return;
                } else if(errCode == 4){
                    popSetting.hide();
                    $('.userImg img').attr('src',list.path);
                    $('.site-info img').attr('src',list.path);
                }
            },
            error:function(data, status, e){
                alert(e)
            }
        });
    });
</script>